Skip to content

Conversation

@innocenzi
Copy link
Member

@innocenzi innocenzi commented Aug 2, 2025

This pull request adds a tap method to all query builders. This is a good way to create reusable scopes:

query(Pilot::class)
	->select()
	->tap(new HasAssignmentScope(AircraftType::PC12))
	->get();

Happy to tweak the naming here if you got better ideas. I initially wanted to use with but it's already used for relationships.

@brendt
Copy link
Member

brendt commented Aug 4, 2025

How about just clone?

@innocenzi
Copy link
Member Author

clone in PHP is usually a method that returns a clone of the current object, that would break expectations :/

I could think of apply or transform as other names, but honestly with is the one that makes the most sense to me. However, due to Laravel, not using with for relations would kind of break expectations as well

@brendt
Copy link
Member

brendt commented Aug 6, 2025

I like transform a lot more than tap! Let's do that?

@innocenzi
Copy link
Member Author

Let's go with transform then! I'll close this PR and add transform to #1458 because I'd rather avoid the conflicts in the rebase 😭

@innocenzi innocenzi closed this Aug 7, 2025
@brendt brendt deleted the feat/query-tap branch September 16, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants